package com.action.log;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.beans.log.LogTag;
import com.business.log.LogTagBus;
import com.config.SystemGlobals;

public class ManageTag extends HttpServlet {

	private static final long serialVersionUID = 1L;
	
	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {

		String contentType = SystemGlobals.getValue("contentType");
		PrintWriter out = response.getWriter();
		response.setContentType(contentType);

		if (request.getParameter("deleted") != null) {
			String[] tagIds = request.getParameterValues("deleted");
			LogTagBus ltb = new LogTagBus();
			ltb.del(tagIds);
			out
					.println("<script>alert(\"删除日志Tag成功\");window.location=\"admin/blog/taglist.jsp\";</script>");
			out.close();
		}
		if (request.getParameter("edit") != null) {
			String tagName = request.getParameter("tagname");
			String viewCount = request.getParameter("viewcount");
			LogTag lt = new LogTag();
			lt.setTagName(tagName);
			lt.setViewCount(viewCount);
			LogTagBus ltb = new LogTagBus();
			String tagId = request.getParameter("id");
			ltb.update(lt, tagId);
			out
					.println("<script>alert(\"修改Tag成功\");window.location=\"admin/blog/taglist.jsp\";</script>");
			out.close();
		}
	}

}
